package com.platform.wechat.controller;

import com.platform.wechat.common.JsonBean;
import com.platform.wechat.entity.Registration;
import com.platform.wechat.service.RegistrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @author gpx
 * @company XXXX公司
 * @create 2021-07-28 15:02
 */
@RestController
@RequestMapping("registration")
public class RegistrationController {

    @Autowired
    private RegistrationService registrationService;

    /** 
    * @Description: 时间范围查询（今天+最近七天）传入号源状态，医院Id查询符合条件的医生集合
    * @Param: [status, hospitalId] 
    * @return: com.platform.wechat.common.JsonBean 
    * @Author: guopeixin
    * @Date: 2021/7/28 
    * @Time: 19:23        
    */
    @GetMapping("getVisitTime")
    public JsonBean getVisitTime(Integer officesId, Integer hospitalId){
        JsonBean jsonBean = registrationService.selectDoctorByTime(officesId, hospitalId);
        //System.err.println(jsonBean);
        return jsonBean;
    }

    /**
     * @Description: 更具医院，科室，医生职称，姓名查询
     * @Param: [hospitalName, officesName, doctorTitle, doctorName]
     * @return: com.platform.wechat.common.JsonBean
     * @Author: guopeixin
     * @Date: 2021/7/28
     * @Time: 21:56
     */
    @GetMapping("getDoctor")
    public JsonBean getDoctor(String hospitalName, String officesName, String doctorTitle, String doctorName){
        //System.err.println(hospitalName+officesName+doctorTitle+doctorName+"////////////");
        JsonBean jsonBean = registrationService.selectDoctor(hospitalName, officesName, doctorTitle, doctorName);
        //System.err.println(jsonBean.getData());
        return jsonBean;
    }

    /**
     * 根据电话查就诊人
     * @param session
     * @return
     */
    @RequestMapping("selectName")
    public JsonBean select(HttpSession session){
        Object platformPhone = session.getAttribute("platformPhone");
        String s = String.valueOf(platformPhone);
        JsonBean jsonBean = registrationService.selectName(s);
        //System.err.println(jsonBean);
        return jsonBean;
    }

    /**
     * 根据就诊人查订单
     * @param patientName
     * @return
     */
    @RequestMapping("select")
    public JsonBean select(String patientName){
        return registrationService.select(patientName);
    }

    /**
     * 查询订单详细信息
     * @param registrationId
     * @return
     */
    @RequestMapping("information")
    public JsonBean s(Integer registrationId){
        return registrationService.selects(registrationId);
    }

    /** 
    * @Description: 添加Registration 挂号记录
    * @Param: [registration] 
    * @return: com.platform.wechat.common.JsonBean 
    * @Author: guopeixin
    * @Date: 2021/7/28 
    * @Time: 22:55
    */
    @GetMapping("insertRegistration")
    public JsonBean insertRegistration(Registration registration){
        JsonBean jsonBean = registrationService.insertRegistrationRecord(registration);
        return jsonBean;
    }


}
